package com.dwxt.sport.controller;

import com.dwxt.common.annotation.ValidateFiled;
import com.dwxt.common.annotation.ValidateGroup;
import com.dwxt.common.base.BaseResult;
import com.dwxt.common.util.PartyUtil;
import com.dwxt.sport.dao.RunBodyMapper;
import com.dwxt.sport.entity.RunBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/sport/run")
@RestController
public class RunBodyController {

    @Autowired
    private RunBodyMapper runBodyMapper;

    @RequestMapping("/create")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0, filedName = "random", notNull = true),
            @ValidateFiled(index = 0, filedName = "body", notNull = true),
    })
    public BaseResult create(RunBody runBody) {
        runBody.setUserId(PartyUtil.getCurrentUserId());
        runBodyMapper.insertSelective(runBody);
        return BaseResult.ok();
    }
}
